<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

<title>绑定手机</title>

<link rel="stylesheet" type="text/css" href="__PUBLIC__/wechat/css/weui.min.css">

<link rel="stylesheet" type="text/css" href="__PUBLIC__/wechat/css/demos.css">
</head>

<body ontouchstart>
<div class="weui_cell">
<div  style=" text-align: center!important;position:absolute;top:0px;left:0px;width:100%;padding-top:5px;padding-bottom:5px;font-size: 15px; background:red;filter:alpha(Opacity=60);-moz-opacity:0.6;opacity: 0.6;color:#FFFFFF; display:none;" id="dialog1"></div></div>
<form  action="wechat/bind" method="post" id="form" >
  <h3 style="margin-bottom:10px; margin-top:40px; text-align: center;"><img src="{$user_info['headimgurl']}" style="border-radius:50%;width:80px;height:80px;" /></h3>
  <h3 class="demos-title" style="margin-bottom:30px;color:#000000;font-size: 20px;">{$user_info['nickname']}</h3>
  <div class="weui_cells">

<div class="weui_cell">
    <div class="weui_cell_hd">
      <label class="weui_label">手机号：</label>
    </div>
    <div class="weui_cell_bd weui_cell_primary">
      <input class="weui_input" type="tel" id="tell" name="tell" placeholder="输入手机号" value="{$account['phone']?$account['phone']:''}"  >
    </div>
</div>
      
<div class="weui_cell">
    <div class="weui_cell_hd">
      <label class="weui_label">用户名：</label>
    </div>
    <div class="weui_cell_bd weui_cell_primary">
        <input class="weui_input" type="text" id="user_name" name="user_name" placeholder="输入用户名" value="{$account['user_name']?$account['user_name']:''}">
    </div>
</div>
      
  <div class="weui_cell">
    <div class="weui_cell_hd">
      <label class="weui_label">密码：</label>
    </div>
    <div class="weui_cell_bd weui_cell_primary">
      <input class="weui_input" type="password" id="password" name="password" placeholder="输入密码" value="{$account['password']?$account['password']:''}">
    </div>
  </div>
  </div>
<input  type="hidden" id="openid" name="openid"  value="{$user_info['openid']}">
  {if condition="empty($account)"}
  <div class="weui_btn_area" style="margin-top:100px"> <a class="weui_btn weui_btn_primary" type="submit" id="submit">绑定</a> </div>
  {else}
  <div class="weui_btn_area" style="margin-top:100px"> <a class="weui-btn weui-btn_disabled weui-btn_default" href="javascript:void(0);">已绑定</a> </div>
  {/if}
</form>

<script type="text/javascript" src="__PUBLIC__/others/jquery.min-2.2.1.js" ></script>
<script type="text/javascript">


$("#submit").click(function(){
	if($("#tell").val()==""){
		$("#dialog1").text("请输入手机号");
		$("#dialog1").show();
		setTimeout("codefans()",3000);
		return false;
	}
	var reg=/^1[0-9]{10}/;
	if(!reg.test($("#tell").val())){
		$("#dialog1").text("手机格式错误");
		$("#dialog1").show();
		setTimeout("codefans()",3000);
		return false;
     }
	
	 if($("#user_name").val()==""){
		$("#dialog1").text("请输入共享系统用户名");
		$("#dialog1").show();
		setTimeout("codefans()",3000);
		return false;
	}
	if($("#password").val()==""){
		$("#dialog1").text("请输入共享系统密码");
		$("#dialog1").show();
		setTimeout("codefans()",3000);
		return false;
	}
        var phoneNum = $("#tell").val();
	var openid = $("#openid").val();
        var user_name = $("#user_name").val();
        var password = $("#password").val();
	$.ajax({
            type: "POST",
            dataType:'json',
            url: "{:url('wechat/bind')}",
            data:{'phone':phoneNum,'openid':openid,user_name:user_name,password:password},
			success: function(data) {
				//alert(data.data);
				if(data.state==200){
					$("#dialog1").css('background','green');
					$("#dialog1").text("绑定成功");
					$("#dialog1").show();
					setTimeout("disappear()",3000);
				}else{
					$("#dialog1").text("绑定失败");
					$("#dialog1").show();
					setTimeout("codefans()",3000);
					return false;
				}
			}
	 });
});

function codefans(){
	$("#dialog1").hide();
}
</script>
</body>
</html>
